home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-06-26 | 2.1 KB | 92 lines | [TEXT/?bDv] |
- !
- ! Zapper
- !
- ! This bot recognizes when it takes damage, and it tries to run
- ! away when it gets hit.
- ! Its primary weapon is a standard gun. However, it has a
- ! secondary laser which it fires at the corners of the arena,
- ! just in case any bots are lurking there.
- !
-
- #DATA
-
- EQU INCR 23
-
- DEF damage
- DEF scanAt
- DEF xx ! Destination coordinates
- DEF yy
- DEF goX ! Prepared velocities for running away
- DEF goY
- DEF temp
-
- #CODE BASIC
-
- Gosub CalcPos ! Pick a point to go to
- goX = goX * 20 ! Prepare to accelerate an awful lot
- goY = goY * 20
-
- :Initialize
- damage = $DAMAGE ! Remember current damage level
-
- While (damage <> $DAMAGE) ! Until I get hit
- begin
- scanAt = scanAt + INCR
- Scan Angle scanAt
- While ($FOUND <> 0) ! Until I lose sight of enemy
- begin
- Fire Weapon 1, Angle $ANGLE
- If (damage <> $DAMAGE) Then Goto Runaway
- ! Jump out if damage is taken while locked
- Scan Angle $ANGLE
- end
- end
-
- Goto Runaway
-
- :RAway
- Gosub CalcVel
- goX = goX * 2 ! Move there twice as fast.
- goY = goY * 2
- :RUNAWAY
- VELOCITY GOX, GOY
- If (xx-$XLOC > 30) Then Goto RAway
- If (xx-$XLOC < -30) Then Goto RAway
- If (yy-$YLOC > 30) Then Goto RAway
- If (yy-$YLOC < -30) Then Goto RAway
-
- Velocity 0, 0
-
- Gosub CalcPos ! Pick a point to go to
- goX = goX * 20 ! Prepare to accelerate an awful lot
- goY = goY * 20
-
- ! Before returning to the scan loop, Do a quick zap into
- ! the four corners of the arena. However, if the battery
- ! has been destroyed, don't bother.
-
- If ($BATTERY == 0) Then Goto Initialize
-
- damage = $DAMAGE
- Fire Weapon 2, Angle ArcTan(-$YLOC, -$XLOC)
- If (damage <> $DAMAGE) Then Goto Runaway
- Fire Weapon 2, Angle ArcTan(-$YLOC, 256-$XLOC)
- If (damage <> $DAMAGE) Then Goto Runaway
- Fire Weapon 2, Angle ArcTan(256-$YLOC, 256-$XLOC)
- If (damage <> $DAMAGE) Then Goto Runaway
- Fire Weapon 2, Angle ArcTan(256-$YLOC, -$XLOC)
- If (damage <> $DAMAGE) Then Goto Runaway
-
- Goto Initialize ! Start all over again.
-
-
- :CalcPos
- xx = Random(215) + 20
- yy = Random(215) + 20
- :CalcVel
- goX = xx - $XLOC
- goY = yy - $YLOC
- Return
-
- #END
-